<?php

/**
 * pages actions.
 *
 * @package    dolpheuscms
 * @subpackage pages
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class pagesActions extends sfActions
{

    /**
     * Executes index action
     *
     * @param sfRequest $request A request object
     */
    public function executeIndex(sfWebRequest $request)
    {
        $this->pages = Doctrine_Core::getTable('Pages')->getFirstPage();

        // Loop through pages object and setLayout
        foreach($this->pages as $page)
        {
            // remove the .php from the template in the database
            $layout = substr($page['template'], 0, -4);
            // set the layout for this page
            $this->setLayout($layout);
        }
    }

    /**
     * Executes view action
     *
     * @param sfRequest $request A request object
     */
    public function executeView(sfWebRequest $request)
    {
        $this->pages = Doctrine_Core::getTable('Pages')->getPageName($request->getParameter('url'));
        $this->forward404Unless($this->pages->count());
        
        // Loop through pages object and setLayout
        foreach($this->pages as $page)
        {
            // remove the .php from the template in the database
            $layout = substr($page['template'], 0, -4);
            // set the layout for this page
            $this->setLayout($layout);
        }
    }

}
